<?php

ini_set('magic_quotes_gpc',1);
define('IN_DISCUZ','1');
    require_once($_SERVER['DOCUMENT_ROOT']."/collect/reset/t.class.php");
    require_once($_SERVER['DOCUMENT_ROOT']."/collect/reset/collect_base.php");
    require_once($_SERVER['DOCUMENT_ROOT']."/collect/reset/collect_tongyong.php");
    require_once(APP_PATH . "Common/yzs1013_pldr.php");
    require_once($_SERVER['DOCUMENT_ROOT']."/collect/Lib/org/zqnews.class.php");


    if($_POST){
	    $url=$_POST['url'];
	}else{
		$url=$_GET['url'];
	}

	if(preg_match("/s=1/Uisx",$url)){
	   $ywj=curl3($url);
	}
    $host=host($url);
    switch($_REQUEST['gather_type']){
        case 1:
        $keyword="nr";break;
        case 2:
        $keyword="bbs";break;
        case 2:
        $keyword="video";break;
    }

    $t=new t($config['DB_HOST'],$config['DB_USER'],$config['DB_PWD'],"longzs");
    if($_REQUEST['b1']){
     $re=jcre($_POST['re']);
     $titlere=jcre($_POST['titlere']);
     $delete=jcre($_POST['delete']);
     $pre_delete=jcre($_POST['pre_delete']);
     $puhuo=jcre($_POST['puhuo']);
	 $dd=preg_split("/\|\|\||$/m",$_POST['nextpage']);
	 for($j=0;$j<count($dd);$j++){
		 if(preg_match("/[a-zA-Z0-9_\-\.]+\.(gif|jpg|jpeg|png|bmp)$/Uisx",trim($dd[$j]))){
			$nextpage2.="<img[^<>]+src=[^<>]*".addsla($dd[$j])."[^<>]*>";
		 }else{
            $nextpage2.="\r\n".trim($dd[$j]);
         }
	 }
     $nextpage=jcre($nextpage2);
	 $data=array(
	   'titlere'=>$titlere,
	   're'=>$re,
	   'delete'=>$delete,
	   'titlere'=>$titlere,
	   'pre_delete'=>$pre_delete,
	   'exec'=>$_POST['exec'],
	   'functions'=>$_POST['functions'],
	   'loadimg'=>$_POST['loadimg'],
	   'nextpage'=>$nextpage,
       'puhuo'=>$puhuo,
	   'cookie'=>$_POST[cookie],
	   'keyword'=>$keyword,
	   'host'=>$host,
	   'updatetime'=>date("Y-m-d H:i:s"),
	 );
     //print_r($data);
        //将re入库
     $t->rk("longzs_re", "", "host='$host' and keyword='$keyword'", array('insert'=>1,'key'=>'id','autoadd'=>1,'dataarray'=>$data,'keyarray'=>array(),'qzsxarray'=>array(),'bug'=>1),$data);
	 echo "<script>alert('OK')</script>";
	 exit;
    }
	//echo "select * from longzs_re where host='".trim(host($url))."' and keyword='".$keyword."'";
    $rs=$t->sqlone("select * from longzs_re where host='".trim(host($url))."' and keyword='".$keyword."'");

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>


<title>标题结果替换</title>
<script>
function submits(){
	cpform.target="ifr";
	cpform.action="http://bbs.longsunhd.com/source/class/collect/longsun_collect_set.php?b1=1";
	cpform.submit();
	cpform.target="ifr1";
	cpform.action="http://bbs2.longsunhd.com/source/class/collect/longsun_collect_set.php?b1=1";
	cpform.submit();
}

</script>
</head>

<body topmargin="0" leftmargin="0">
<iframe id=ifr name=ifr frameborder=0 width=0 height=0></iframe>
<iframe id=ifr1 name=ifr1 frameborder=0 width=0 height=0></iframe>
<h1>配置<?echo $host;?>网站的采集规则(<?echo $rs['id'];?>)</h1>
<br><a target=_blank href="http://collect2.longsunhd.com/collect/index.php?gather_type=1&s_url=<?=urlencode($_GET['url'])?>&s=0.6188209886074043&bug=2">http://collect2.longsunhd.com/collect/index.php?gather_type=1&s_url=<?=urlencode($_GET['url'])?>&s=0.6188209886074043&bug=2</a>
<form id="cpform"  autocomplete="on" method="post" name="cpform">
<input type=hidden name="url" value="<?=$_GET['url']?>">
<input type=hidden name="gather_type" value="<?=$_GET['gather_type']?>">
标题结果替换:<textarea style="width:98%;height:40px" name=titlere><?=$rs['titlere']?></textarea><br>
内容匹配正则:<textarea style="width:98%;height:60px" name=re><?=cn2utf8($rs['re'])?></textarea><br>
执行php:<textarea style="width:98%;height:60px" name=exec><?=$rs['exec']?></textarea><br>
源码预先替换:<textarea style="width:98%;height:60px" name=pre_delete><?=cn2utf8($rs['pre_delete'])?></textarea><br>
结果替换:<textarea style="width:98%;height:60px" name=delete><?=cn2utf8($rs['delete'])?></textarea><br>
分页图片文件名称:<textarea style="width:98%;height:60px" name=nextpage><?=$rs['nextpage']?></textarea><br>
图片无法显示时选:<input style="width:20px;" name=loadimg value="<?=$rs['loadimg']?>">
出现乱码时选:<input style="width:20px;" name=y value="<?=$rs['y']?>"><br>
捕获:<textarea style="width:98%;height:60px" name=puhuo><?=cn2utf8($rs['puhuo'])?></textarea><br>
<input type="button" name="b1" value="保存" onclick="submits()">
<textarea style="width:98%;height:30px"  name="functions"><?=$rs['functions']?></textarea>
<textarea style="width:98%;height:30px"  name="cookie"><?=$rs['cookie']?></textarea>
</form>
</body>
</html>
